import mongoose,{Schema,Document} from 'mongoose';

export interface IDogDocument extends Document{
    order:  number;
    title: string;
    video: string;
    poster: string;
    url: string;
    price: string;
    category: string;
    _doc: IDogDocument;
}

const DogSchema:Schema<IDogDocument>=new Schema({
    order:  Number,
    title: String,
    video: String,
    poster: String,
    url: String,
    price: String,
    category: String,
},{
    timestamps:true,
    toJSON: {
        transform: (_doc:any,result:any,options: any)=>{
            result.id= result._id,
            delete result._id;
            delete result.__v;
            delete result.createdAt;
            delete result.updatedAt;
            return result;
        }
    }
});

export const Dog=mongoose.model<IDogDocument>("Dog",DogSchema,"dogs");